<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko">
<head>
    <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'> 
    <title>Project Outland: </title>
	<link type="text/css" href="http://jqueryui.com/themes/base/ui.theme.css" rel="stylesheet" /> 
	<link type="text/css" href="http://jqueryui.com/themes/base/ui.base.css" rel="stylesheet" /> 
    <link type="text/css" href="http://jqueryui.com/demos/demos.css" rel="stylesheet" /> 
    <link type="text/css" href="/static_media/css/outlandlist.css" rel="stylesheet" /> 
    
    <script type="text/javascript" src="/static_media/js/jquery-1.3.2.min.js"></script>
    <script type="text/javascript" src="/static_media/js/jquery-ui-1.7.1.custom.min.js"></script>

    <script type="text/javascript">
    var reco = {}
    var selectedShop = ''

    function addMenu(item)
    {
        if(selectedShop != item)
        {
            $('#menu_div').stop(false,true)
            $('#menulist').stop(false,true)
            selectedShop = item;
            $('#menu_div').hide();
            $('#menulist').hide();

       $.get('/outland/list/ajaxHtml/menu/'+encodeURI(item),
                function(data)
                {
                $('#menu_div').queue(function(){
                    $('#menu_div').html($('<div></div>').attr('id','menulist').html(data));
                    $('#menulist').show();
                    $('#menu_div').fadeIn(100);
                    $(this).dequeue();
                    })
                
                })
        }
    }
    function writeReco(shop,menu,value)
    {
        if(!reco[shop])
        {
            reco[shop]={};
        }
        reco[shop][menu]=value;
    }
    function saveResult()
    {
        gen = {};
        for(shop in reco)
        {
            for(menu in reco[shop])
            {
               gen[shop+'___'+menu] = reco[shop][menu]; 
            }
        }
        $.getJSON('/outland/list/save',gen,function(data){alert(data.s)});
    } 

    $(function(){
            $.ajaxSetup({ scriptCharset: "utf-8" , contentType: "application/json; charset=utf-8"});
            $('#menu_div').hide()

            $('#cate_div').tabs({spinner: '',fx: { opacity: 'toggle',duration:200 }
                ,select: function(event, ui) {
                $('#menu_div').hide()
                $('#menulist').hide()
                }
                });
		    $.getJSON('/outland/list/json/category',
            function(data)
            {
                $.each(data.name_list,
                    function(i,item)
                    {
					$('#cate_div').tabs('add','/outland/list/ajaxHtml/shop/'+encodeURI(item),item);
                    }
                    );
            }
            );
            $('#submitButton').click(
            function()
            {
            saveResult()
            return false;
            });
        }
        );

    </script>

</head>

<body>

<div id='pollBody'>
<h1>Outland Project Poll</h1>
<form action="/outland/list/save" method="post">
    <table>
        <tr><th><label for="id_id">ID:</label></th><td><input type="text" name="id" id="id_id" /></td></tr>
        <tr><th><label for="id_pass1">Password:</label></th><td><input type="password" name="pass" id="id_pass1" /></td></tr>
        <tr><th><label for="id_pass2">Password Check:</label></th><td><input type="password" name="pass" id="id_pass2" /></td></tr>
        <tr><input id='submitButton' type=submit value="결과 저장하기"></tr>
    </table>
<input type="hidden" name="q">
    <div id='body'>
<div id="cate_div">
    <ul id="cate_list">
    </ul>
</div>
<div id='menu_div' class='ui-tabs ui-widget ui-widget-content ui-corner-all'></div>
</div>

</div><!--pollbody ends-->
</body>

</form>
</html>
